﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SistemaAcademicoBO.Entities;
using SistemaAcademicoBLL;

namespace SistemaAcademico
{
    public partial class MasterPage : System.Web.UI.MasterPage
    {
        #region FIELDS
        ApplicationFacade facade = new ApplicationFacade();
        #endregion

        #region PAGE EVENTS
        protected void Page_Load(object sender, EventArgs e)
        {
            User user = new User();
            try
            {
                user = facade.GetUser((int)(Session["userId"]));
                switch (user.UserAlcada)
                {

                    case 0:
                        lblNomeUsuario.Text = "MASTER";
                        break;

                    case 1:
                        Professor professor = facade.GetProfessor(Convert.ToInt32(user.ReferenceId));
                        lblNomeUsuario.Text = "Olá, " + professor.Nome;
                        break;

                    case 2:
                        Student student = facade.GetStudent(new Guid(user.ReferenceId));
                        lblNomeUsuario.Text = "Olá, " + student.Nome;
                        break;
                    default:

                        break;
                }
            }
            catch
            {
                lblNomeUsuario.Text = "Olá, " + user.UserLogin;
            }
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            Page.Header.DataBind();
        }
        #endregion
    }
}